#ifndef __WPTH_ARTBUTTON_H__
#define __WPTH_ARTBUTTON_H__

#include "defs.h"

class ArtPanel;
class ArtButton;

class ArtButtonEvent : public wxCommandEvent
{
public:
	ArtButtonEvent(wxEventType commandType, int winid)
		: wxCommandEvent(commandType, winid)
		, isDown(false)
		, m_button(NULL)
	{

	}

	void SetButtonObj(ArtButton* obj) { m_button = obj; }
	ArtButton* GetButtonObj() const { return m_button; }

public:
	bool isDown;
protected:
	ArtButton* m_button;
};

class ArtButton : public wxControl
{
	enum
	{
		None = 0,
		HOVER = 1,
		CLICK = 2
	};
public:
	ArtButton() {}
	ArtButton(ArtPanel *parent,
		wxWindowID id,
		const wxString& label,
		const wxBitmap& bitmap,
		const wxPoint& pos = wxDefaultPosition,
		const wxSize& size = wxDefaultSize,
		long style = wxNO_BORDER,
		const wxString& name = wxStaticTextNameStr);
	virtual ~ArtButton() {}

	void SetLabel(const wxString &label);
	void SetBitmap(const wxBitmap& bitmap);
	void SetBackground(const wxBitmap& bitmap);
	void SetBackgroundHover(const wxBitmap& bitmap);

	inline wxVisualAttributes GetDefaultAttributes() const;
	bool ShouldInheritColours() const { return false; }
	bool Enable(bool enable = true);

	bool SetForegroundColour(const wxColour& colour);
	void SetDefault();
	void Notify();
protected:
	void OnPaint(wxPaintEvent& event);
	void OnSize(wxSizeEvent& event);
	void OnEraseBackground(wxEraseEvent& event);
	void OnLeftDown(wxMouseEvent& event);
	void OnLeftUp(wxMouseEvent& event);
	void OnMouseLeave(wxMouseEvent& event);
	void OnMouseEnter(wxMouseEvent& event);
	void OnGainFocus(wxFocusEvent& event);
	void OnLoseFocus(wxFocusEvent& event);

	bool AcceptsFocus() const;
	wxSize DoGetBestSize() const;

protected:
	int m_mouseAction;
	ArtPanel* m_artPanel;
	wxBitmap m_bitmap;
	wxBitmap m_bgHoverBitmap;
	wxBitmap m_bgBitmap;
	bool m_hasFocus;

	DECLARE_CLASS(ArtButton)
	DECLARE_EVENT_TABLE()
};
#endif